import java.util.Scanner;

/**
 * @Title: 子矩阵的和
 * @Author 贾金博
 * @Package PACKAGE_NAME
 * @Date 2024/3/3 20:10
 * @description: 二维前缀和
 */
public class 子矩阵的和 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int q = sc.nextInt();

        int[][] a = new int[n + 10][m + 10];
        int[][] s = new int[n + 10][m + 10]; // 预处理的前缀和

        for(int i = 1; i <= n; ++ i ) {
            for(int j = 1; j <= m; ++ j ) {
                a[i][j] = sc.nextInt();
                s[i][j] = s[i - 1][j] + s[i][j - 1] - s[i - 1][j - 1] + a[i][j];
            }
        }

        while (q -- != 0) {
            int x1, y1, x2, y2;
            x1 = sc.nextInt();
            y1 = sc.nextInt();
            x2 = sc.nextInt();
            y2 = sc.nextInt();
            System.out.println(s[x2][y2] - s[x1 - 1][y2] - s[x2][y1 - 1] + s[x1 - 1][y1 - 1]); // 只要是带1的都去-1
        }
    }
}
